<?php
// +----------------------------------------------------------------------
// | Description: 客户
// +----------------------------------------------------------------------
// | Author: Michael_xu | gengxiaoxu@5kcrm.com
// +----------------------------------------------------------------------

namespace app\crm\controller;

use app\admin\controller\ApiCommon;
use app\admin\model\User;
use Exception;
use think\Hook;
use think\Request;
use think\Db;
use PHPExcel_IOFactory;

//分配外勤
class Assignfield extends ApiCommon
{
    /**
     * 用于判断权限
     * @permission 无限制
     * @allow 登录用户可访问
     * @other 其他根据系统设置
     **/
    public function _initialize()
    {
        $action = [
            'permission'=>['index','userlist','assign'],
            'allow'=>['']
        ];
        Hook::listen('check_auth',$action);
        $request = Request::instance();
        $a = strtolower($request->action());
        if (!in_array($a, $action['permission'])) {
            parent::_initialize();
        } else {
            $param = Request::instance()->param();
            $this->param = $param;
        }
    }


    /**
     * 获取所有外勤列表
     * */
    public function userlist()
    {
        $where=["group_id"=>31];
        $group = db('admin_access')->where($where)->column("user_id");
        $data=User::whereIn("id",$group)->select();
        return resultArray(['data' => $data]);
    }
}